package com.leolian.spring02.activemq;
import javax.jms.JMSException;  
import javax.jms.Message;  
import javax.jms.Session;  
  


import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jms.core.JmsTemplate;  
import org.springframework.jms.core.MessageCreator;  
import org.springframework.stereotype.Component;
  
/**
 * @author Administrator
 * @description 生产者
 */
@Component
public class SpringProducer {  
    
    //Spring的模板，封装了很多功能 
	@Autowired
    private JmsTemplate jmsTemplate;  
    
    public void send() {  
        //使用JMSTemplate可以很简单的实现发送消息  
        jmsTemplate.send(new MessageCreator() {  
            public Message createMessage(Session session) throws JMSException {  
                return session.createTextMessage("地瓜！地瓜！");  
            }  
        });
    }

}  